import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;


public class DomainWithoutMain {

	 String filePath = "C:\\test3.txt";
	    BufferedReader br;
	    String s ;
	    String line;
	    String read;
	    List<String> tempsPredicate = new LinkedList<String>();
	    List<String> tempsType = new LinkedList<String>();
	    String[] predicate;
	    String[] type;

	    public DomainWithoutMain(){
			   line = "";
			   read="";

	    }
	public String[] predicate(){
		
		
		 try {
		    	
		        br = new BufferedReader(new FileReader(filePath));
		        try {
		        	
		            while((line = br.readLine()) != null)
		            {
		            	
		        		read=br.readLine();
                //MAHER: split with space, tab, and new lines
		            	String[] words = line.split(" ");
		            	

		            	 for (String word : words) {

		          	 if(word.equals("(:predicates")){
		          	
		           		 while((read = br.readLine()) != null){
		            	  tempsPredicate.add(read);
		           		 
		               	 }
		           	 }
		            	 }
		           
		                }
		            
	           		 predicate	 = tempsPredicate.toArray(new String[0]);

		            
		            br.close();
		           
		        } catch (IOException e) {
		            // TODO Auto-generated catch block
		            e.printStackTrace();
		        }
		    } catch (FileNotFoundException e) {
		        // TODO Auto-generated catch block
		        e.printStackTrace();
		    }
		    
              return predicate;
	}
	public String[] type(){
		try {
	        br = new BufferedReader(new FileReader(filePath));
	        try {
	            while((line = br.readLine()) != null)
	            {

	            	
	            	String[] words = line.split("//");

	                for (String word : words) {
	                  if (word.equals("(:types") ) {
                        //MAHER: be careful because the file can be all put in one line, or every word in a line. (THE PARSER SHOULD BE SMART ENOUGH).
	                	  line=br.readLine();
	                	  while((read = br.readLine()) != null){
	                    	  tempsType.add(line);
	                          if (word.equals("(:predicates") );
	                        	  break;
	                   
	                   		 }
	                   // 	  String [] types=type[0].split(" ");

	                   //       System.out.println(type[1]+"*");
	                  }
	                 	                	               
	                }
	            }
	         
           		type = tempsType.toArray(new String[0]);
	            
	            br.close();
	           
	        } catch (IOException e) {
	            // TODO Auto-generated catch block
	            e.printStackTrace();
	        }
	    } catch (FileNotFoundException e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
	    }
	return type;

	}
	
}
